﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using Convertor.Interface;
using Wpf.CommonTools.SystemExtension;

namespace Convertor.Plugin.Combin
{
    [Serializable]
    public class ConfigContent : IConfigContent, ISerializable, ICloneable, INotifyPropertyChanged
    {
        private Encoding fileEncoding = Encoding.Default;

        public Encoding FileEncoding
        {
            get { return fileEncoding; }
            set { fileEncoding = value; if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("ToolTip")); } }
        }

        public ConfigContent()
        {
        }

        public override string ToString()
        {
            return FileEncoding.EncodingName;
        }

        #region IToolTip 成员

        public string ToolTip
        {
            get { return string.Format(UILanguage.TryFindResource("Plugin_ReadFromDiske_Info"), fileEncoding.EncodingName); }
        }

        #endregion

        #region ISerializable 成员

        public void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            info.AddValue("FileEncoding", FileEncoding, typeof(Encoding));
        }

        public ConfigContent(SerializationInfo info, StreamingContext context)
        {
            fileEncoding = (Encoding)info.GetValue("FileEncoding", typeof(Encoding));
        }

        #endregion

        #region ICloneable 成员

        public object Clone()
        {
            ConfigContent a = new ConfigContent()
            {
                FileEncoding = this.FileEncoding
            };
            return a;
        }

        #endregion

        #region INotifyPropertyChanged 成员

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }
}
